﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace Pibby.Core.ViewModels
{
	public class EpisodeSelection
	{
		public string Id
		{
			get;
			set;
		}

		public string Name
		{
			get;
			set;
		}

		public DateTime PublicationDate
		{
			get;
			set;
		}

		public bool IsSelected
		{
			get;
			set;
		}

		public string Podcast
		{
			get;
			set;
		}
	}

	public class EpisodeSelectionCollection : Collection<EpisodeSelection>
	{
		ReadOnlyCollection<string> SelectedEpisodes
		{
			get
			{
				List<string> ids = new List<string>();

				foreach (EpisodeSelection e in this.Items)
				{
					if (e.IsSelected)
						ids.Add(e.Id);
				}

				return new ReadOnlyCollection<string>(ids);
			}
		}

		public void SelectAll()
		{
			foreach (EpisodeSelection e in this.Items)
			{
				e.IsSelected = true;
			}
		}

		public void ClearAll()
		{
			foreach (EpisodeSelection e in this.Items)
			{
				e.IsSelected = false;
			}
		}
	}
}
